#include <bits/stdc++.h>
using namespace std;
#define int long long

void solve() {
    int n, m , k, h;
    cin >> n >> m >> k >> h;
    int t = (m - 1) * k;
    int ans = 0;
    for(int i = 0; i < n; i++) {
        int x;
        cin >> x;
        if(x == h) continue;
        if(abs(x - h) <= t && abs(x - h) % k == 0) ans++;
    }
    cout << ans << endl;
}

signed main() {
    int t;
    cin >> t;
    while(t--) solve();
    return 0;
}